﻿#include "pch.h"

#include "../../GeoAlg/src/sim_geo_alg.h"
#include "../Geometry/geometryTools.h"
using std::cout;
using std::endl;
using namespace sim_geo_alg;
TEST(GeometryTest, Chacheng) {
	auto res1 = GeometryTools::isLeft(0, 0, 0, 1, 1, 1);
	cout << res1 << endl;
}

TEST(MathU, m1) {
	sim_geo_alg::GWire wire1;
	wire1.vertices = {GPoint{50, 0}, GPoint{50, 30}, GPoint{100, 30}, GPoint{100, 60}, GPoint{50, 60}, GPoint{50, 90}};
	sim_geo_alg::GWire wire2;
	wire2.vertices = {GPoint{50, 0}, GPoint{50, 30}, GPoint{100, 30}, GPoint{100, 60}, GPoint{50, 60}, GPoint{50, 90}};
	bool b = wire_left_wire(wire1, wire2, 1E-3);
	EXPECT_TRUE(!b);
	cout << b << endl;
}

TEST(MathU, m2) {
	sim_geo_alg::GWire wire1;
	wire1.vertices = {GPoint{50, 0}, GPoint{50, 30}, GPoint{100, 30}, GPoint{100, 60}, GPoint{50, 60}, GPoint{50, 90}};
	sim_geo_alg::GWire wire2;
	wire2.vertices = {GPoint{100, 0}, GPoint{100, 30}, GPoint{50, 30}, GPoint{50, 60}, GPoint{100, 60}, GPoint{100, 90}};
	bool b = wire_left_wire(wire1, wire2, 1E-3);
	EXPECT_TRUE(b);
	cout << b << endl;
}


TEST(MathU, m3) {
	sim_geo_alg::GWire wire1;
	wire1.vertices = {GPoint{50, 0}, GPoint{50, 50}, GPoint{100, 30}, GPoint{100, 70}, GPoint{50, 60}, GPoint{50, 90}};
	sim_geo_alg::GWire wire2;
	wire2.vertices = {GPoint{50, 0}, GPoint{50, 30}, GPoint{100, 50}, GPoint{100, 60}, GPoint{50, 70}, GPoint{50, 90}};
	bool b = wire_left_wire(wire1, wire2, 1E-3);
	EXPECT_TRUE(b);
	cout << b << endl;
}

TEST(MathU, m4) {
	sim_geo_alg::GWire wire1;
	wire1.vertices = { GPoint{50, 0}, GPoint{50, 50}, GPoint{100, 30}, GPoint{100, 70}, GPoint{50, 60}, GPoint{50, 90} };
	sim_geo_alg::GWire wire2;
	wire2.vertices = { GPoint{50, 0}, GPoint{50, 50}, GPoint{100, 30}, GPoint{100, 70}, GPoint{50, 60}, GPoint{50, 90} };
	bool b = wire_left_wire(wire1, wire2, 1E-3);
	EXPECT_TRUE(!b);
	cout << b << endl;
}



TEST(seg, inter1) {
	sim_geo_alg::GSegment geg = {GPoint(0,0),GPoint(0,100) };
	sim_geo_alg::GSegment geg1 = {GPoint(0,0),GPoint(0,100) };
	const bool b = quick_deny_inter(geg, geg1, 1E-3);
	EXPECT_TRUE(b);
	cout << b << endl;
}

TEST(seg, inter2) {
	sim_geo_alg::GSegment geg = { GPoint(0,0),GPoint(0,100) };
	sim_geo_alg::GSegment geg1 = { GPoint(0.1,0),GPoint(0,100) };
	const bool b = quick_deny_inter(geg, geg1, 1E-3);
	const bool b1 = quick_deny_inter(geg1, geg, 1E-3);
	EXPECT_TRUE(b);
	EXPECT_TRUE(b1);
	cout << b << endl;
}

TEST(seg, inter3) {
	sim_geo_alg::GSegment geg1 = { GPoint(0,0),GPoint(0,100) };
	sim_geo_alg::GSegment geg = { GPoint(0.1,0),GPoint(0,100) };
	const bool b = quick_deny_inter(geg, geg1, 1E-3);
	EXPECT_TRUE(b);
	cout << b << endl;
}

TEST(seg, inter4) {
	sim_geo_alg::GSegment geg1 = { GPoint(0,0),GPoint(0,100) };
	sim_geo_alg::GSegment geg = { GPoint(0.1,0),GPoint(0.1,100) };
	const bool b = quick_deny_inter(geg, geg1, 1E-3);
	EXPECT_TRUE(!b);
	cout << b << endl;
}

TEST(seg, inter5) {
	sim_geo_alg::GSegment geg1 = { GPoint(0,0),GPoint(100,100) };
	sim_geo_alg::GSegment geg = { GPoint(100.1,0),GPoint(100.1,100) };
	const bool b = quick_deny_inter(geg, geg1, 1E-3);
	EXPECT_TRUE(!b);
	cout << b << endl;
}